package com.gitee.wsl.prism4j

import com.gitee.wsl.prism4j.annotations.PrismBundle
import kotlin.test.Test
import kotlin.test.BeforeTest

@PrismBundle(includeAll = true, grammarLocatorClassName = ".GrammarLocatorGrammarUtils")
class GrammarUtilsTest {
    private lateinit var grammarLocator: GrammarLocator
    private lateinit var prism4j: Prism4j

    @BeforeTest
    fun before() {
        grammarLocator = MyGrammarLocator()
        prism4j = Prism4j(grammarLocator)
    }


    val test_keyword="""
      private lateinit var grammarLocator: GrammarLocator
      private lateinit var prism4j: Prism4j

    @Before
    fun before() {
        grammarLocator = MyGrammarLocator()
        prism4j = Prism4j(grammarLocator)
    }
        
    """.trimIndent()

    @Test
    fun test() {
        val grammar = prism4j.grammar("kotlin")!!
        val nodes = prism4j.tokenize(test_keyword, grammar)
        val visitor = object : Prism4j.Visitor {
            override fun visit(nodes: List<Prism4j.Node>) {
                for (node in nodes) {
                    println(node)
                }
            }
        }
        visitor.visit(nodes)
    }

}
